var flag=1;
var obj=$.ajax({
	type:"get",
	url:"lun_list.json",
	async:false,
	success:function(response,status,xhr){
		console.log(response);
	}
})

function Lun(obj){
	this.id1=obj.id1;
	this.src=obj.src;
	this.gbtitle=obj.gbtitle;
	this.gb_detail=obj.gb_detail;
	this.gb_result=obj.gb_result;
	this.gb_sta=obj.gb_sta;
	this.gbauthod=obj.gbauthod;
	this.book_title=obj.book_title;
	this.book_detail=obj.book_detail;
	
	this.id2=obj.id2;
	this.src2=obj.src2;
	this.m_title=obj.m_title;
	this.gengx=obj.gengx;
	this.progress=obj.progress;
}
Lun.prototype={
	init:function(){
		$("<li></li>").html('<img src="'+this.src+'" alt="" width="242px" height="242px"><ul id="l_left"><li><span class="g_title">'+this.gbtitle+'</span><span class="g_detail">查看剧情详情</span>'+
			'</li><li><span>更新至</span><span class="g_col">'+this.gb_result+'</span></li><li><span>'+this.gb_sta+'</span><span>'+this.gbauthod+'</span></li>'+
			'<li title="'+this.book_title+'"><span>简介:</span><span>'+this.book_detail+'</span></li></ul>').appendTo($("#glun_ul"));
	},
	m_con:function(){
		$("<li></li>").html('<img src="'+this.src2+'" width="150px" height="150px"><p>'+this.m_title+'</p><span>'+this.gengx+'</span><span>'+this.progress+'</span>').appendTo($("#mi_list"));
	}
}

$.each(obj.responseJSON.g_list,function(i,e){
	var lun=new Lun(e);
	lun.init();
})

// $.each(obj.responseJSON.m_good,function(i,e){
// 	var lun2=new Lun(e);
// 	lun2.m_con();
// })

// function Two(){
// 	window.location.href = "gb2.html";
// }

var i=0;
function Animat(t){
	if(t){
		i=i+t;
	}
	if(i==6){	
		$("#glun_ul").animate({"left":"0px"},0);
		i=1;
	}
	if(i==-1){
		$("#glun_ul").animate({"left":"-3290px"},0);
		i=5;
	}
	$(".gb1_cricle>li").eq(i%5).css("background","black").siblings().css("background","#cecccb");
	$("#glun_ul").animate({"left":-658*i+"px"},1000);
}
$(".gb1_cricle>li").eq(0).css("background","black").siblings().css("background","#cecccb");
var timer=setInterval(Animat,4000,1);
$(".gb1_cricle>li").click(function(){
	i=$(this).index();
	console.log(1)
	$(".gb1_cricle>li").eq($(this).index()).css("background","black");
	// $(".gb1_cricle>li").eq(i).css("background","black");
	Animat();
})

// console.log($("#mi_list>li").length);
$("#mi_list>li").each(function(i,e){
	if(i>=4){
		$(this).css("marginTop","15px");
	}
	if(i%4==0){
		$(this).css("marginLeft","0");
	}
	
 });
 // console.log($(".item4>span").length);
 $(".item4>span").each(function(i,e){
     // console.log($(this).index());
 	// console.log(i);
	
 	// if(i%4==0&&i!=0){
 	// 	$(this).css("marginLeft","50px");
 	// }
	if(i%4==0&&i>3){
		$(this).css("marginLeft","50px");
		$(this).css("marginTop","10px");
	}
	if(i==24){
		$(this).css("marginLeft","40px");
	}
	if(i==27){
		$(this).css("marginLeft","56px");
	}
	if(i==28){
		$(this).css("marginLeft","10px");
	}
	if(i==29){
		$(this).css("marginTop","10px");
		$(this).css("marginLeft","56px");
	}
	if(i==30){
		$(this).css("marginLeft","10px");
	}
	if(i>23){
		$(this).css("display","none");
	}
	
  });


$(".gb_more").click(function(){
	$(".item4>span").each(function(i,e){
		if(i>23){
			$(this).css("display","inline-block");
		}
	})
})

